 /* 
 * File:   cPhisycs.h
 * Author: josep
 *
 * Created on 14 / desembre / 2010, 02:57
 */

#include "cTiledScene.h"
#include "cAutonomousAgent.h"
#include "c2DArea.h"
#include "Globals.h"
#include "cLateralPlayer.h"

#ifndef CPHYSICS_H
#define	CPHYSICS_H

#define DEFAULT_FRICTION_FACTOR 1
#define DEFAULT_GRAVITATIONAL_ACCELERATION 1

class cPhysicalObject;

class cPhysics {
public:
    cPhysics();
    cPhysics(int DImensionX, int DImensionY, int OriginX=0, int OriginY=0);
    cPhysics(const cPhysics& orig);
    virtual ~cPhysics();
    void Init(int DImensionX, int DImensionY, int visibility,
                                int OriginX=0, int OriginY=0);
    void Init();
    void ProcessNextStep(cPhysicalObject* PhysicalObject, int time);
    void SetOriginX(int Origin);
    void SetOriginY(int Origin);
    const int* GetOrigin() const;
    void SetDimensionX(int Dimension);
    void SetDimensionY(int Dimension);
    const int* GetDimension() const;
    void SetDefaultFrictionFactor(float DefaultFrictionFactor);
    float GetDefaultFrictionFactor() const;
    void SetGravitationalAcceleration(float GravitationalAcceleration);
    float GetGravitationalAcceleration() const;
    void SetVisibility(int visibility);
    int GetVisibility() const;
    void SetScene(cTiledScene* Scene);
    void SetAgents(list<cPhysicalObject*>* agents);
    void SetObjects(list<cPositionedObject*>* objects);
    void SetPlayer(cLateralPlayer* Player);
private:
    int Origin[2];
    int Dimension[2];
    float DefaultFrictionFactor;
    float GravitationalAcceleration;
    void CollidesMapFloor(cPhysicalObject *PhysicalObject, cTiledScene *Scene);
    int CollidesMapWall(cPhysicalObject *PhysicalObject, cTiledScene *Scene);
    int CollidesMapRoof(cPhysicalObject *PhysicalObject, cTiledScene *Scene);
    void CollidesPhysicalObject(cPhysicalObject *PhysicalObject1, cPhysicalObject *PhysicalObject2);
    int CollidesArea(c2DArea* area1, c2DArea* area2);
    int visibility;
    vector< vector<int> > visionMatrix;
    cLateralPlayer * Player;
    list<cPositionedObject*> *objects;
    list<cPhysicalObject*> *agents;
    cTiledScene *Scene;
};

#endif	/* CPHYSICS_H */

